package com.gjy.util;

import java.util.Random;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2022-09-27 17:45:13
 */
public class SaltUtil {

    /**
     * 生成指定位数的随机盐值
     *
     * @param n 随机盐值的位数
     * @return 随机盐值
     */
    public static String getSalt(int n) {
        char[] chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234567890!@#$%^&*()".toCharArray();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            char aChar = chars[new Random().nextInt(chars.length)];
            sb.append(aChar);
        }
        return sb.toString();
    }
}